import Vue from 'vue'
import VueRouter from 'vue-router'

// 懒加载路由组件
const Login = () => import(/* webpackChunkName: "login_home_welcome" */ '@/components/Login.vue')
const Home = () => import(/* webpackChunkName: "login_home_welcome" */ '@/components/Home.vue')
const Welcome = () => import(/* webpackChunkName: "login_home_welcome" */ '@/components/Welcome.vue')

const Users = () => import(/* webpackChunkName: "Users_Roles_Rights" */ '@/components/users/Users.vue')
const Roles = () => import(/* webpackChunkName: "Users_Roles_Rights" */ '@/components/power/Roles.vue')
const Rights = () => import(/* webpackChunkName: "Users_Roles_Rights" */ '@/components/power/Rights.vue')


const List = () => import(/* webpackChunkName: "Goods" */ '@/components/goods/List.vue')
const Cate = () => import(/* webpackChunkName: "Goods" */ '@/components/goods/Cate.vue')
const Params = () => import(/* webpackChunkName: "Goods" */ '@/components/goods/Params.vue')
const Add = () => import(/* webpackChunkName: "Goods" */ '@/components/goods/Add.vue')

const Order = () => import(/* webpackChunkName: "Order" */ '@/components/order/Order.vue')

const Report = () => import(/* webpackChunkName: "Report" */ '@/components/report/Report.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {path: '/login', component: Login},
  {path: '/home', component: Home, redirect: '/welcome', children: [
    {path: '/welcome', component: Welcome, name: 'welcome'},
    {path: '/users', component: Users, name: 'users'},
    {path: '/roles', component: Roles, name: 'roles'},
    {path: '/rights', component: Rights, name: 'rights'},
    {path: '/goods', component: List, name: 'goods'},
    {path: '/categories', component: Cate, name: 'cate'},
    {path: '/params', component: Params, name: 'params'},
    {path: '/goods/add', component: Add, name: 'add'},
    {path: '/orders', component: Order, name: 'orders'},
    {path: '/reports', component: Report, name: 'reports'},
  ]},
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
